cmake_minimum_required(VERSION 3.11)
project(editorwidget LANGUAGES CXX)

# 设置静态库
set(LIBRARY_TYPE STATIC)

# 启用自动处理 Qt 元对象系统
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

# 设置 C++17 标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 查找 Qt 组件
find_package(Qt5 REQUIRED COMPONENTS Core Widgets PrintSupport)


# 设置包含目录
include_directories(
    include
    ${Qt5Core_INCLUDE_DIRS}
    ${Qt5Widgets_INCLUDE_DIRS}
    ${Qt5Gui_INCLUDE_DIRS}
)

# 源文件列表
set(SOURCES
	editorwidget.cpp
)

# 头文件列表
set(HEADERS
	editorwidget.h
)

# 创建静态库
add_library(editorwidget ${LIBRARY_TYPE}
    ${SOURCES}
    ${HEADERS}
)

# 链接 Qt 库
target_link_libraries(editorwidget PRIVATE
    Qt5::Core
    Qt5::Widgets
    Qt5::Gui
    Qt5::PrintSupport
)

# 设置目标属性
set_target_properties(editorwidget PROPERTIES
    OUTPUT_NAME "editorwidget"
    ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)

# 安装规则
install(TARGETS editorwidget
    ARCHIVE DESTINATION lib
    PUBLIC_HEADER DESTINATION include/editorwidget
)

install(DIRECTORY include/
    DESTINATION include/editorwidget
    FILES_MATCHING PATTERN "*.h"
)